-- =====================================================================
-- 
--   File:      setup.sql
--   Summary:   This file contains the TSQL that must be run to support the OleDb_TVP sample.
--  
--   Date:      January 11, 2008
-- 
-- ---------------------------------------------------------------------
-- 
--   This file is part of the Microsoft SQL Server Code Samples.
--   Copyright (C) Microsoft Corporation.  All rights reserved.
-- 
-- This source code is intended only as a supplement to Microsoft
-- Development Tools and/or on-line documentation.  See these other
-- materials for detailed information regarding Microsoft code samples.
-- 
-- THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF 
-- ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
-- PARTICULAR PURPOSE.
-- 
-- ===================================================================== 

create database testdb
go
use testdb
go
create table tblEmployees (
id int identity primary key,
name nvarchar(50) not null,
birthday date null,
salary int null,
photograph varbinary(max) null
)
go

create type tvpEmployees as table(
name nvarchar(50) not null,
birthday date null,
salary int null,
photograph varbinary(max) null
)
go

create procedure insertEmployees @tvpEmployees tvpEmployees readonly, 
@id int output as
insert tblEmployees(name, birthday, salary, photograph)
select name, birthday, salary, photograph from @tvpEmployees
select @id = coalesce(scope_identity(), -1)
go